import Cookies from 'weapp-cookie'
import { request } from '@/util/request.js'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey, 'example.com')
}

export function setToken(token) {
  return Cookies.set(TokenKey, token, { domain: 'example.com'})
}

export function removeToken() {
  return Cookies.remove(TokenKey, 'example.com')
}


export function getInfo(data) {
  return request({
    url: 'getInfo',
    method: 'get',
    data
  })
}

//登录方法
export function login(username, password, code, uuid) {
  const data = {
    username,
    password,
    code,
    uuid
  }
  return uni.request({
    url: 'http://www.findoma.com/green-api/login',
    method: 'post',
    data: data
  })
}

// 退出方法
export function logout() {
  return uni.request({
    url: '/logout',
    method: 'post'
  })
}